<%@page import="com.glowdayz.glowmee.dao.ProductDAO"%>
<%@page import="com.glowdayz.glowmee.cmd.ProductCMD"%>
<%@page import="com.glowdayz.common.PageHandler"%>
<%@page import="com.glowdayz.common.MultipartBox.FileInfo"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.glowdayz.common.DateTime"%>
<%@page import="com.glowdayz.common.ApiHandler"%>
<%@page import="com.glowdayz.common.DBHandler"%>
<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%
	DBHandler.getInstance().connect();
	
	ApiHandler web = new ApiHandler(request, out, "JSPglowmee");
	
	int pro1, pro2, pro3, pro4, pro5, pro6, pro7, pro8, pro9, pro10;
	
	pro1 = web.getInt("pro1");
	pro2 = web.getInt("pro2");
	pro3 = web.getInt("pro3");
	pro4 = web.getInt("pro4");
	pro5 = web.getInt("pro5");
	pro6 = web.getInt("pro6");
	pro7 = web.getInt("pro7");
	pro8 = web.getInt("pro8");
	pro9= web.getInt("pro9");
	pro10 = web.getInt("pro10");
	
	int[] productArr = {pro1, pro2, pro3, pro4, pro5, pro6, pro7, pro8, pro9, pro10};
	
	ArrayList<ProductCMD> list = ProductDAO.getInstance().getProductImg(productArr);

	if (list == null) {
		DBHandler.getInstance().disconnect();
		web.result(null, "데이터 조회에 실패했습니다. 잠시후 다시 시도해 주세요.");
		return;
	}
	
	DBHandler.getInstance().disconnect();
%>
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
	<channel>
		<!-- ##### 이 데이터를 소개하는 부분 (필수항목들) ##### -->
		<!-- 제목 -->
		<title>글로우미</title>
		<!-- XML 생성일시 -->
		<pubDate><%=DateTime.getInstance().getNowDateTimeString()%></pubDate>
		
		<!-- ##### 게시물 정보 반복 처리 ##### -->
		<!-- 추가적인 정보를 덧붙이거나, 필요 없는 정보는 삭제 가능함 -->
		<%
			if (list != null) {
				for (int i=0; i<list.size(); i++) {
					ProductCMD item = list.get(i);
					FileInfo productFile = item.getProductImg();
		%>
		<item>
			<!-- 제품 항번 -->
			<idProduct><![CDATA[<%=item.getIdProduct()%>]]></idProduct>
			<!-- 제품 이미지 -->
			<%
			if (productFile != null) {
			%>
			<productImage><![CDATA[/glowmee/download.jsp?<%=productFile.toString("utf-8")%>]]></productImage>
			<productThumbnail><![CDATA[/glowmee/download.jsp?<%=productFile.toString("utf-8")%>&size=100]]></productThumbnail>
			<%} else {%>
			<productImage>null</productImage>
			<productThumbnail>null</productThumbnail>
			<%}%>
		</item>
		<%
				}
			}
		%>
	</channel>
</rss>